/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ReportesJefeMercadeoUI.java
 *
 * Created on 28/06/2009, 12:50:04 AM
 */

package CRM_UI;

import DAO.DAOArticulo;
import DAO.DAOCampaNaArticulo;
import DAO.DAOEmpleadoCampana;
import java.util.Vector;

/**
 *
 * @author L¡z
 */
public class ReportesJefeMercadeoUI extends javax.swing.JFrame {

    /** Creates new form ReportesJefeMercadeoUI */
    Vector <String> columnasTabla = new Vector <String>();
    Vector <Vector> datosTabla = new Vector <Vector>();
    String labelTabla = "";

    public ReportesJefeMercadeoUI()
    {
        initComponents();
        setLocationRelativeTo(null);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        reportesButtonGroup = new javax.swing.ButtonGroup();
        jPanel2 = new javax.swing.JPanel();
        productosCatRadioButton = new javax.swing.JRadioButton();
        jLabel1 = new javax.swing.JLabel();
        campaNaProductoRadioButton = new javax.swing.JRadioButton();
        generarButton = new javax.swing.JButton();
        jLabel9 = new javax.swing.JLabel();
        aNoComboBox = new javax.swing.JComboBox();
        mesComboBox = new javax.swing.JComboBox();
        mercaderistasCampaNaRadioButton = new javax.swing.JRadioButton();

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Reportes"));

        reportesButtonGroup.add(productosCatRadioButton);
        productosCatRadioButton.setText("Cantidad de Articulos por Categoría");
        productosCatRadioButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                productosCatRadioButtonActionPerformed(evt);
            }
        });

        jLabel1.setText("Seleccione el reporte que desea generar:");

        reportesButtonGroup.add(campaNaProductoRadioButton);
        campaNaProductoRadioButton.setText("Campañas realizadas por articulo");
        campaNaProductoRadioButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                campaNaProductoRadioButtonActionPerformed(evt);
            }
        });

        generarButton.setText("generar");
        generarButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                generarButtonActionPerformed(evt);
            }
        });

        jLabel9.setText("fecha:");

        aNoComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1980", "1981", "1982", "1983", "1984", "1985", "1986", "1987", "1988", "1989", "1990", "1991", "1992", "1993", "1994", "1995", "1996", "1997", "1998", "1999", "2000", "2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008", "2009" }));

        mesComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "        -", "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre" }));

        reportesButtonGroup.add(mercaderistasCampaNaRadioButton);
        mercaderistasCampaNaRadioButton.setText("Mercaderistas que participan en Campañas");
        mercaderistasCampaNaRadioButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mercaderistasCampaNaRadioButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(productosCatRadioButton)
                        .addGroup(jPanel2Layout.createSequentialGroup()
                            .addComponent(jLabel9)
                            .addGap(12, 12, 12)
                            .addComponent(mesComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(aNoComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(campaNaProductoRadioButton)
                    .addComponent(mercaderistasCampaNaRadioButton))
                .addContainerGap(54, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap(114, Short.MAX_VALUE)
                .addComponent(generarButton)
                .addGap(110, 110, 110))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(18, 18, 18)
                .addComponent(productosCatRadioButton)
                .addGap(15, 15, 15)
                .addComponent(mercaderistasCampaNaRadioButton)
                .addGap(18, 18, 18)
                .addComponent(campaNaProductoRadioButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(aNoComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(mesComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9))
                .addGap(18, 18, 18)
                .addComponent(generarButton)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void productosCatRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_productosCatRadioButtonActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_productosCatRadioButtonActionPerformed

    private void campaNaProductoRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_campaNaProductoRadioButtonActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_campaNaProductoRadioButtonActionPerformed

    private void generarButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_generarButtonActionPerformed
        // TODO add your handling code here:
        if( productosCatRadioButton.isSelected() )
        {
            columnasTabla.clear();
            datosTabla.clear();
            labelTabla = "";

            DAOArticulo objDaoArticulo = new DAOArticulo();
            datosTabla = objDaoArticulo.articulosCategoria();
            columnasTabla.addElement("Codigo");
            columnasTabla.addElement("Nombre Categoria");
            columnasTabla.addElement("Cantidad de Articulos");

        }
        if( mercaderistasCampaNaRadioButton.isSelected() )
        {
            columnasTabla.clear();
            datosTabla.clear();
            labelTabla = "";

            DAOEmpleadoCampana objDaoEmpleadoCampana = new DAOEmpleadoCampana();
            datosTabla = objDaoEmpleadoCampana.empleadosEnCampaNas();
            columnasTabla.addElement("Cedula");
            columnasTabla.addElement("Nombre Empleado");
            columnasTabla.addElement("Codigo Campaña");
            columnasTabla.addElement("Nombre Campaña");
        }
        if( campaNaProductoRadioButton.isSelected() )
        {
            String aNo = aNoComboBox.getSelectedItem().toString();
            columnasTabla.clear();
            datosTabla.clear();
            labelTabla = "";
            String fechaInicio = "";
            String fechaFin = "";

            if( mesComboBox.getSelectedIndex() == 0 )
            {
                fechaInicio = "01"+"-"+"01"+"-"+aNo;
                fechaFin = "31-"+"12-"+aNo;
            }
            else
            {
                if(mesComboBox.getSelectedIndex() <= 9)
                {
                    fechaInicio = "01-"+"0"+mesComboBox.getSelectedIndex()+"-"+aNo;
                    fechaFin = "31-"+"0"+mesComboBox.getSelectedIndex()+"-"+aNo;
                }
                else
                {
                    fechaInicio = "01-"+mesComboBox.getSelectedIndex()+"-"+aNo;
                    fechaFin = "31-"+mesComboBox.getSelectedIndex()+"-"+aNo;
                }
            }

            DAOCampaNaArticulo objCampaNaArticulo = new DAOCampaNaArticulo();
            datosTabla = objCampaNaArticulo.articulosCampaNa(fechaInicio,fechaFin);
            columnasTabla.addElement("Codigo Articulo");
            columnasTabla.addElement("Nombre Articulo");
            columnasTabla.addElement("Cantidad Campañas");
        }

        TablaReportesUI tabla = new TablaReportesUI(datosTabla, columnasTabla,labelTabla);
        tabla.setVisible(true);
}//GEN-LAST:event_generarButtonActionPerformed

    private void mercaderistasCampaNaRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mercaderistasCampaNaRadioButtonActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_mercaderistasCampaNaRadioButtonActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new ReportesJefeMercadeoUI().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox aNoComboBox;
    private javax.swing.JRadioButton campaNaProductoRadioButton;
    private javax.swing.JButton generarButton;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JRadioButton mercaderistasCampaNaRadioButton;
    private javax.swing.JComboBox mesComboBox;
    private javax.swing.JRadioButton productosCatRadioButton;
    private javax.swing.ButtonGroup reportesButtonGroup;
    // End of variables declaration//GEN-END:variables

}
